home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / sys / RCS / scsi.h,v < prev    next >
Text File  |  1992-03-06  |  36KB  |  1,015 lines

  1. head     1.4;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    mani:1.4; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.4
  10. date     92.03.06.12.16.38;  author mani;  state Exp;
  11. branches ;
  12. next     1.3;
  13.  
  14. 1.3
  15. date     91.09.02.14.07.30;  author jhh;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     91.07.26.17.14.40;  author jhh;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     91.06.25.15.20.22;  author jhh;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 1.4
  35. log
  36. @Added some data structures (ScsiInquiryCommand, ScsiReserveCommand, etc.)
  37. as well as the #define's for jukebox commands (SCSI_MOVE_MEDIUM, etc.).
  38. @
  39. text
  40. @/*
  41.  * scsi.h --
  42.  *
  43.  *    Common declarations for SCSI command formaters. This file only covers
  44.  *    definitions pertaining to the SCSI common command set that are
  45.  *    common to all SCSI device types (ie disk, tapes, WORM, printers, etc).
  46.  *    Device sepecific command format can be found in scsi{Disk,Tape,WORM}.h
  47.  *    SCSI protocol releated declarations can be found in scsiHBA.h.
  48.  *    Definitions for the SCSI device sub-system. Some of the following
  49.  *      references from the proceedings of the 1984 Mini/Micro Northeast
  50.  *    Conference might be useful in understanding SCSI. 
  51.  *
  52.  *
  53.  * Copyright 1988 Regents of the University of California
  54.  * Permission to use, copy, modify, and distribute this
  55.  * software and its documentation for any purpose and without
  56.  * fee is hereby granted, provided that the above copyright
  57.  * notice appear in all copies.  The University of California
  58.  * makes no representations about the suitability of this
  59.  * software for any purpose.  It is provided "as is" without
  60.  * express or implied warranty.
  61.  *
  62.  * $Header: /sprite/src/lib/include/sys/RCS/scsi.h,v 1.3 91/09/02 14:07:30 jhh Exp Locker: mani $ SPRITE (Berkeley)
  63.  */
  64.  
  65. #ifndef _SCSI_H
  66. #define _SCSI_H
  67.  
  68. #include <machparam.h>
  69.  
  70. #ifndef BYTE_ORDER
  71. BYTE_ORDER is not defined
  72. #endif
  73. /*
  74.  * "Standard" SCSI Commands. SCSI command are divided into 8 group as
  75.  * follows:
  76.  *    Group0    (0x00 - 0x1f).  Basic commands. 6 bytes long
  77.  *    Group1    (0x20 - 0x3f).  Extended command. 10 bytes.
  78.  *    Group2    (0x40 - 0x5f).    Reserved.
  79.  *    Group2    (0x60 - 0x7f).    Reserved.
  80.  *    Group2    (0x80 - 0x9f).    Reserved.
  81.  *    Group2    (0xa0 - 0xbf).    Reserved.
  82.  *    Group6    (0xc0 - 0xdf).    Vendor Unique
  83.  *    Group7    (0xe0 - 0xff).  Vendor Unique
  84.  *    
  85.  *
  86.  */
  87.  
  88. /*
  89.  * Scsi Group0 commands all are 6 bytes and have a format according to 
  90.  * struct ScsiGroup0Cmd.
  91.  */
  92.  
  93. #define SCSI_TEST_UNIT_READY    0x00
  94. #define SCSI_REZERO_UNIT    0x01
  95. #define SCSI_REQUEST_SENSE    0x03
  96. #define    SCSI_FORMAT_UNIT    0x04
  97. #define SCSI_REASSIGN_BLOCKS    0x07
  98. #define SCSI_READ        0x08
  99. #define SCSI_WRITE        0x0a
  100. #define SCSI_SEEK        0x0b
  101. #define SCSI_INQUIRY        0x12
  102. #define SCSI_MODE_SELECT    0x15
  103. #define    SCSI_RESERVE_UNIT    0x16
  104. #define    SCSI_RELEASE_UNIT    0x17
  105. #define SCSI_COPY        0x18
  106. #define SCSI_MODE_SENSE        0x1A
  107. #define SCSI_START_STOP        0x1b
  108. #define    SCSI_RECV_DIAG_RESULTS    0x1c
  109. #define SCSI_SEND_DIAGNOSTIC    0x1d
  110. #define SCSI_PREVENT_ALLOW     0x1e
  111. /*
  112.  * Group1 commands are all 10 bytes and have a format according to
  113.  * struct ScsiGroup1Cmd.
  114.  */
  115. #define SCSI_READ_CAPACITY     0x25    
  116. #define    SCSI_READ_EXT        0x28
  117. #define    SCSI_WRITE_EXT        0x2a
  118. #define    SCSI_SEEK_EXT        0x2b
  119. #define    SCSI_WRITE_VERIFY    0x2e
  120. #define    SCSI_VERIFY_EXT        0x2f
  121. #define    SCSI_SEARCH_HIGH    0x30
  122. #define SCSI_SEARCH_EQUAL    0x31
  123. #define    SCSI_SEARCH_LOW        0x32
  124. #define    SCSI_SET_LIMITS        0x33
  125. #define    SCSI_COMPARE        0x39
  126. #define    SCSI_COPY_VERIFY    0x3a
  127.  
  128.  
  129. /*
  130.  * Group-0 commands for sequential access devices.
  131.  */
  132.  
  133. #define SCSI_REWIND        0x01
  134. #define SCSI_READ_BLOCK_LIMITS    0x05
  135. #define    SCSI_TRACK_SELECT    0x0b
  136. #define    SCSI_READ_REVERSE    0x0f
  137. #define SCSI_WRITE_EOF        0x10
  138. #define SCSI_SPACE        0x11
  139. #define    SCSI_VERIFY        0x13
  140. #define    SCSI_READ_BUFFER    0x14
  141. #define SCSI_ERASE_TAPE        0x19
  142. #define    SCSI_LOAD_UNLOAD    0x1b
  143.  
  144. /*
  145.  * Group-1 commands for sequential access devices.
  146.  */
  147. #define SCSI_LOCATE        0x2b
  148. #define SCSI_READ_POSITION    0x34
  149.  
  150. /*
  151.  * Commands for a medium-changer (jukebox) device.
  152.  */
  153. #define SCSI_MOVE_MEDIUM    0xa5
  154. #define SCSI_POSITION_ELEMENT    0x2b
  155. #define SCSI_INIT_ELEM_STATUS    0xe7
  156. #define SCSI_READ_ELEM_STATUS    0xb8
  157.  
  158.  
  159. /*
  160.  * The standard group-0 6-byte SCSI control block.  Note that the 
  161.  * fields between highAddr and blockCount inclusive are command dependent.
  162.  * The definitions Addr and BlockCount cover most of the commands we will
  163.  * use.
  164.  */
  165.  
  166. typedef struct ScsiGroup0Cmd {
  167. #if BYTE_ORDER == BIG_ENDIAN
  168.     unsigned char command;        /* command code, defined below.  The
  169.                      * upper three bits of this are zero
  170.                      * to indicate the control block is
  171.                      * only 6 bytes long */
  172.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  173.                      * pass the command.  The device
  174.                      * has already been selected using
  175.                      * the "targetID" bit. */
  176.     unsigned char highAddr    :5;    /* High bits of address */
  177.     unsigned char midAddr;        /* Middle bits of address */
  178.     unsigned char lowAddr;        /* Low bits of address */
  179.     unsigned char blockCount;        /* Blocks to transfer */
  180.     unsigned char vendor57    :1;    /* Vendor unique bit */
  181.     unsigned char vendor56    :1;    /* Vendor unique bit */
  182.     unsigned char pad1        :4;    /* Reserved */
  183.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  184.     unsigned char link        :1;    /* Another command follows */
  185. #else
  186.     unsigned char command;        /* command code, defined below.  The
  187.                      * upper three bits of this are zero
  188.                      * to indicate the control block is
  189.                      * only 6 bytes long */
  190.     unsigned char highAddr    :5;    /* High bits of address */
  191.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  192.                      * pass the command.  The device
  193.                      * has already been selected using
  194.                      * the "targetID" bit. */
  195.     unsigned char midAddr;        /* Middle bits of address */
  196.     unsigned char lowAddr;        /* Low bits of address */
  197.     unsigned char blockCount;        /* Blocks to transfer */
  198.     unsigned char link        :1;        /* Another command follows */
  199.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  200.     unsigned char pad1        :4;    /* Reserved */
  201.     unsigned char vendor56    :1;    /* Vendor unique bit */
  202.     unsigned char vendor57    :1;    /* Vendor unique bit */
  203. #endif
  204. } ScsiGroup0Cmd;
  205.  
  206. /*
  207.  * SCSI status completion information.  This is returned by the device
  208.  * when a command completes. 
  209.  */
  210.  
  211. typedef struct ScsiStatus {
  212. #if BYTE_ORDER == BIG_ENDIAN
  213.     unsigned char reserved    :1;    /* Reserved. */
  214.     unsigned char vendor06    :1;    /* Vendor unique bit */
  215.     unsigned char vendor05    :1;    /* Vendor unique bit */
  216.     unsigned char intStatus    :1;    /* Intermediate status */
  217.     unsigned char busy        :1;    /* Device busy or reserved */
  218.     unsigned char conditionMet    :1;    /* Condition met */
  219.     unsigned char check        :1;    /* Check the sense data for more info */
  220.     unsigned char vendor00    :1;    /* Vendor unique bit */
  221. #else
  222.     unsigned char vendor00    :1;    /* Vendor unique bit */
  223.     unsigned char check        :1;    /* Check the sense data for more info */
  224.     unsigned char conditionMet    :1;    /* Condition met */
  225.     unsigned char busy        :1;    /* Device busy or reserved */
  226.     unsigned char intStatus    :1;    /* Intermediate status */
  227.     unsigned char vendor05    :1;    /* Vendor unique bit */
  228.     unsigned char vendor06    :1;    /* Vendor unique bit */
  229.     unsigned char reserved    :1;    /* Reserved. */
  230. #endif
  231. } ScsiStatus;
  232.  
  233. /*
  234.  * SCSI_RESERVED_STATUS() - Return TRUE if the status byte has a reserved code.
  235.  */
  236.  
  237. #define    SCSI_RESERVED_STATUS(byte) (byte&0x80)
  238.  
  239.  
  240. /*
  241.  * Sense information provided after some errors.  This is divided into
  242.  * two kinds, classes 0-6, and class 7.  This is 30 bytes big to allow
  243.  * for the drive specific sense bytes that follow the standard 4 byte header.
  244.  *
  245.  * For extended sense, this buffer may be cast into another type.  Also
  246.  * The actual size of the sense data returned is used to detect what
  247.  * kind of tape drive is out there.  Kludgy, but true.
  248.  */
  249. typedef struct ScsiClass0Sense {
  250. #if BYTE_ORDER == BIG_ENDIAN
  251.     unsigned char valid        :1;    /* Sense data is valid */
  252.     unsigned char error        :7;    /* 3 bits class and 4 bits code */
  253.     unsigned char highAddr;        /* High byte of block address */
  254.     unsigned char midAddr;        /* Middle byte of block address */
  255.     unsigned char lowAddr;        /* Low byte of block address */
  256.     unsigned char sense[26];        /* Target specific sense data */
  257. #else
  258.     unsigned char error        :7;    /* 3 bits class and 4 bits code */
  259.     unsigned char valid        :1;    /* Sense data is valid */
  260.     unsigned char highAddr;        /* High byte of block address */
  261.     unsigned char midAddr;        /* Middle byte of block address */
  262.     unsigned char lowAddr;        /* Low byte of block address */
  263.     unsigned char sense[26];        /* Target specific sense data */
  264. #endif
  265. } ScsiClass0Sense;
  266.  
  267. /*
  268.  * Definitions for errors in the sense data.  The error field is specified
  269.  * as a 3 bit class and 4 bit code, but it is easier to treat it as a
  270.  * single 7 bit field.
  271.  */
  272. #define SCSI_NO_SENSE_DATA        0x00
  273. #define SCSI_NOT_READY            0x04
  274. #define SCSI_NOT_LOADED            0x09
  275. #define SCSI_INSUF_CAPACITY        0x0a
  276. #define SCSI_HARD_DATA_ERROR        0x11
  277. #define SCSI_WRITE_PROTECT        0x17
  278. #define SCSI_CORRECTABLE_ERROR        0x18
  279. #define SCSI_FILE_MARK            0x1c
  280. #define SCSI_INVALID_COMMAND        0x20
  281. #define SCSI_UNIT_ATTENTION        0x30
  282. #define SCSI_END_OF_MEDIA        0x34
  283.  
  284. /*
  285.  * The standard "extended" sense data returned by SCSI devices.  This
  286.  * has an error field of 0x70, for a "class 7" error.
  287.  */
  288. typedef struct ScsiClass7Sense {
  289. #if BYTE_ORDER == BIG_ENDIAN
  290.     unsigned char valid        :1;    /* Sense data is valid */
  291.     unsigned char error7    :7;    /* == 0x70 */
  292.     unsigned char pad1;            /* Also "segment number" for copy */
  293.     unsigned char fileMark    :1;    /* File mark on device */
  294.     unsigned char endOfMedia    :1;    /* End of media reached */
  295.     unsigned char badBlockLen    :1;    /* Block length mis-match (Exabyte) */
  296.     unsigned char pad2        :1;
  297.     unsigned char key        :4;    /* Sense keys defined below */
  298.     unsigned char info1;        /* Information byte 1 */
  299.     unsigned char info2;        /* Information byte 2 */
  300.     unsigned char info3;        /* Information byte 3 */
  301.     unsigned char info4;        /* Information byte 4 */
  302.     unsigned char length;        /* Number of additional info bytes */
  303. #else
  304.     unsigned char error7    :7;    /* == 0x70 */
  305.     unsigned char valid        :1;    /* Sense data is valid */
  306.     unsigned char pad1;            /* Also "segment number" for copy */
  307.     unsigned char key        :4;    /* Sense keys defined below */
  308.     unsigned char pad2        :1;
  309.     unsigned char badBlockLen    :1;    /* Block length mis-match (Exabyte) */
  310.     unsigned char endOfMedia    :1;    /* End of media reached */
  311.     unsigned char fileMark    :1;    /* File mark on device */
  312.     unsigned char info1;        /* Information byte 1 */
  313.     unsigned char info2;        /* Information byte 2 */
  314.     unsigned char info3;        /* Information byte 3 */
  315.     unsigned char info4;        /* Information byte 4 */
  316.     unsigned char length;        /* Number of additional info bytes */
  317. #endif
  318. } ScsiClass7Sense;            /* 8 Bytes */
  319.  
  320. /*
  321.  * Key values for standardized sense class 7. 
  322.  */
  323. #define SCSI_CLASS7_NO_SENSE        0
  324. #define SCSI_CLASS7_RECOVERABLE    1
  325. #define SCSI_CLASS7_NOT_READY        2
  326. #define SCSI_CLASS7_MEDIA_ERROR    3
  327. #define SCSI_CLASS7_HARDWARE_ERROR    4
  328. #define SCSI_CLASS7_ILLEGAL_REQUEST    5
  329.  
  330. /*
  331.  * These seem to have different meanings to different vendors....
  332.  */
  333. #define SCSI_CLASS7_MEDIA_CHANGE    6
  334. #define SCSI_CLASS7_UNIT_ATTN        6
  335.  
  336. #define SCSI_CLASS7_WRITE_PROTECT    7
  337. #define SCSI_CLASS7_BLANK_CHECK        8
  338. #define SCSI_CLASS7_VENDOR        9
  339. #define SCSI_CLASS7_POWER_UP_FAILURE    10
  340. #define SCSI_CLASS7_ABORT        11
  341. #define SCSI_CLASS7_EQUAL        12
  342. #define SCSI_CLASS7_OVERFLOW        13
  343. #define SCSI_CLASS7_RESERVED_14        14
  344. #define SCSI_CLASS7_RESERVED_15        15
  345.  
  346. /*
  347.  * Maximum size of sense data that a device can return. 
  348.  */
  349. #define    SCSI_MAX_SENSE_LEN    256
  350.  
  351. /*
  352.  * Data return by the SCSI inquiry command. 
  353.  */
  354.  
  355. typedef struct ScsiInquiryData {
  356. #if BYTE_ORDER == BIG_ENDIAN
  357.     unsigned char     type;        /* Peripheral Device type. See below. */
  358.     unsigned char     rmb:1;        /* Removable Medium bit. */
  359.     unsigned char    qualifier:7;     /* Device type qualifier. */
  360.     unsigned char    version;    /* Version info. */
  361.     unsigned char    reserved:4;    /* reserved. */
  362.     unsigned char    format:4;    /* Response format. */
  363.     unsigned char    length;        /* length of data returned. */
  364. #ifdef notdef
  365.     unsigned char    vendor;        /* Vendor unqiue parameter. */
  366.     unsigned char    reserved2[2];    /* More reserved. */
  367.     char        vendorInfo[8];    /* Vector identification. */
  368.     char        productInfo[8]; /* Product identification. */
  369.     char        firmwareInfo[4]; /* Firmware identification. */
  370. #endif
  371.  
  372.     unsigned char    reserved2[3];    /* Reserved                  */
  373.     unsigned char    vendorID[8];    /* Vendor ID (ASCII)              */
  374.     unsigned char    productID[16];    /* Product ID (ASCII)              */
  375.     unsigned char    revLevel[4];    /* Revision level (ASCII)          */
  376.     unsigned char    revData[8];    /* Revision data (ASCII)          */
  377. #else
  378.     unsigned char     type;        /* Peripheral Device type. See below. */
  379.     unsigned char    qualifier:7;     /* Device type qualifier. */
  380.     unsigned char     rmb:1;        /* Removable Medium bit. */
  381.     unsigned char    version;    /* Version info. */
  382.     unsigned char    format:4;    /* Response format. */
  383.     unsigned char    reserved:4;    /* reserved. */
  384.     unsigned char    length;        /* length of data returned. */
  385.     unsigned char    reserved2[3];    /* Reserved                  */
  386.     unsigned char    vendorID[8];    /* Vendor ID (ASCII)              */
  387.     unsigned char    productID[16];    /* Product ID (ASCII)              */
  388.     unsigned char    revLevel[4];    /* Revision level (ASCII)          */
  389.     unsigned char    revData[8];    /* Revision data (ASCII)          */
  390. #endif
  391. }  ScsiInquiryData;
  392.  
  393.  
  394. /*
  395.  * The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command.
  396.  *
  397.  * SCSI_DISK_TYPE - Direct Access Device.
  398.  * SCSI_TAPE_TYPE - Sequential Access Device.
  399.  * SCSI_PRINTER_TYPE - Printer Device.
  400.  * SCSI_HOST_TYPE - Processor Device.
  401.  * SCSI_WORM_TYPE - Write-Once Read-Multiple Device.
  402.  * SCSI_ROM_TYPE  - Read-Only Direct Access Device.
  403.  * SCSI_SCANNER_TYPE - Scanner device.
  404.  * SCSI_OPTICAL_MEM_TYPE - Optical memory device.
  405.  * SCSI_MEDIUM_CHANGER_TYPE - Medium changer device.
  406.  * SCSI_COMMUNICATIONS_TYPE - Communications device.
  407.  * SCSI_NODEVICE_TYPE - Logical Unit not present or implemented.
  408.  *
  409.  * Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique.
  410.  */
  411. #define    SCSI_DISK_TYPE        0
  412. #define    SCSI_TAPE_TYPE        1
  413. #define    SCSI_PRINTER_TYPE    2
  414. #define    SCSI_HOST_TYPE        3
  415. #define    SCSI_WORM_TYPE        4
  416. #define    SCSI_ROM_TYPE        5
  417. #define    SCSI_SCANNER_TYPE    6
  418. #define    SCSI_OPTICAL_MEM_TYPE    7
  419. #define    SCSI_MEDIUM_CHANGER_TYPE    8
  420. #define    SCSI_COMMUNICATIONS_TYPE    9
  421. #define    SCSI_NODEVICE_TYPE    0x7f
  422.  
  423. /*
  424.  * Standard header for SCSI_MODE_SELECT commands for tapes.
  425.  */
  426.  
  427. typedef struct ScsiTapeModeSelectHdr {
  428. #if BYTE_ORDER == BIG_ENDIAN
  429.     unsigned char    reserved[2];    /* Reserved. */
  430.     unsigned char    reserved2:1;    /*  ""         */
  431.     unsigned char    bufferedMode:3;    /* Type of buffer to be done. */
  432.     unsigned char    speed:4;    /* Drive speed. */
  433.     unsigned char    length;        /* Block descriptor length. */
  434. #else
  435.     unsigned char    reserved[2];    /* Reserved. */
  436.     unsigned char    speed:4;    /* Drive speed. */
  437.     unsigned char    bufferedMode:3;    /* Type of buffer to be done. */
  438.     unsigned char    reserved2:1;    /*  ""         */
  439.     unsigned char    length;        /* Block descriptor length. */
  440. #endif
  441. } ScsiTapeModeSelectHdr;
  442. /*
  443.  * Format of a SCSI_START_STOP command. This is a group 0 command, but
  444.  * the command contents are different.
  445.  */
  446. typedef struct ScsiStartStopCmd {
  447. #if BYTE_ORDER == BIG_ENDIAN
  448.     unsigned char command;        /* 0x1b */
  449.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  450.                      * pass the command.  The device
  451.                      * has already been selected using
  452.                      * the "targetID" bit. */
  453.     unsigned char pad1        :4;    /* Reserved */
  454.     unsigned char immed        :1;    /* Immediate status bit */
  455.     unsigned char pad2;            /* Reserved */
  456.     unsigned char pad3;            /* Reserved */
  457.     unsigned char pad4        :6;    /* Reserved */
  458.     unsigned char loadEject    :1;    /* Load or eject medium */
  459.     unsigned char start        :1;    /* Start or stop medium */
  460.     unsigned char vendor57    :1;    /* Vendor unique bit */
  461.     unsigned char vendor56    :1;    /* Vendor unique bit */
  462.     unsigned char pad5        :4;    /* Reserved */
  463.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  464.     unsigned char link        :1;    /* Another command follows */
  465. #else
  466.     unsigned char command;        /* command code, defined below.  The
  467.                      * upper three bits of this are zero
  468.                      * to indicate the control block is
  469.                      * only 6 bytes long */
  470.     unsigned char immed        :1;    /* Immediate status bit */
  471.     unsigned char pad1        :4;    /* Reserved */
  472.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  473.                      * pass the command.  The device
  474.                      * has already been selected using
  475.                      * the "targetID" bit. */
  476.     unsigned char pad2;            /* Reserved */
  477.     unsigned char pad3;            /* Reserved */
  478.     unsigned char start        :1;    /* Start or stop medium */
  479.     unsigned char loadEject    :1;    /* Load or eject medium */
  480.     unsigned char pad4        :6;    /* Reserved */
  481.     unsigned char link        :1;    /* Another command follows */
  482.     unsigned char linkIntr    :1;    /* Interrupt after linked command */
  483.     unsigned char pad5        :4;    /* Reserved */
  484.     unsigned char vendor56    :1;    /* Vendor unique bit */
  485.     unsigned char vendor57    :1;    /* Vendor unique bit */
  486. #endif
  487. } ScsiStartStopCmd;
  488.  
  489.  
  490. /*
  491.  * Format of a SCSI_READ_EXT command.
  492.  */
  493.  
  494. typedef struct ScsiReadExtCmd {
  495. #if BYTE_ORDER == BIG_ENDIAN
  496.     unsigned char command;        /* command code. */
  497.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  498.                      * pass the command.  The device
  499.                      * has already been selected using
  500.                      * the "targetID" bit. */
  501.     unsigned char dpo        :1;    /* Disable page out. */
  502.     unsigned char fua        :1;    /* Force unit access. */
  503.     unsigned char pad1        :2;    /* Reserved. */
  504.     unsigned char relAddr    :1;    /* Who knows? */
  505.     unsigned char highAddr;        /* High bits of address. */
  506.     unsigned char highMidAddr;        /* High middle bits of address. */
  507.     unsigned char lowMidAddr;        /* Low middle bits of address. */
  508.     unsigned char lowAddr;        /* Low bits of address */
  509.     unsigned char pad2;            /* Reserved. */
  510.     unsigned char highCount;        /* High bits of number to transfer */
  511.     unsigned char lowCount;        /* Low bits of number to transfer */
  512.     unsigned char vendor    :2;    /* Vendor specific. */
  513.     unsigned char pad        :4;    /* Reserved. */
  514.     unsigned char flag        :1;    /* Flag bit. See SCSI doc. */
  515.     unsigned char link        :1;    /* Link commands. */
  516. #else
  517.     unsigned char command;        /* command code. */
  518.     unsigned char relAddr    :1;    /* Who knows? */
  519.     unsigned char pad1        :2;    /* Reserved. */
  520.     unsigned char fua        :1;    /* Force unit access. */
  521.     unsigned char dpo        :1;    /* Disable page out. */
  522.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  523.                      * pass the command.  The device
  524.                      * has already been selected using
  525.                      * the "targetID" bit. */
  526.     unsigned char highAddr;        /* High bits of address. */
  527.     unsigned char highMidAddr;        /* High middle bits of address. */
  528.     unsigned char lowMidAddr;        /* Low middle bits of address. */
  529.     unsigned char lowAddr;        /* Low bits of address */
  530.     unsigned char pad2;            /* Reserved. */
  531.     unsigned char highCount;        /* High bits of number to transfer */
  532.     unsigned char lowCount;        /* Low bits of number to transfer */
  533.     unsigned char link        :1;    /* Link commands. */
  534.     unsigned char flag        :1;    /* Flag bit. See SCSI doc. */
  535.     unsigned char pad        :4;    /* Reserved. */
  536.     unsigned char vendor    :2;    /* Vendor specific. */
  537. #endif
  538. } ScsiReadExtCmd;
  539.  
  540. /*
  541.  * The SCSI_WRITE_EXT command had the same format as SCSI_READ_EXT.
  542.  */
  543.  
  544. typedef struct ScsiReadExtCmd ScsiWriteExtCmd;
  545.  
  546. /* 
  547.  * Data returned by the SCSI_READ_BLOCK_LIMITS command.
  548.  */
  549.  
  550. typedef struct {
  551.     unsigned char    pad1;
  552.     unsigned char    max2;    /* MSB of max block size. */
  553.     unsigned char    max1;    /* ... */
  554.     unsigned char    max0;    /* LSB of max block size. */
  555.     unsigned char    min1;    /* MSB of min block size. */
  556.     unsigned char    min0;    /* LSB of min block size. */
  557. } ScsiBlockLimits;
  558.  
  559. /*
  560.  * Format of a SCSI_MODE_SENSE command. 
  561.  */
  562. typedef struct {
  563. #if BYTE_ORDER == BIG_ENDIAN
  564.     unsigned char command;        /* 0x1b */
  565.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  566.                      * pass the command.  The device
  567.                      * has already been selected using
  568.                      * the "targetID" bit. */
  569.     unsigned char pad1        :1;    /* Reserved */
  570.     unsigned char disableBlockDesc :1;    /* Disable block descriptor */
  571.     unsigned char pad2        :3;    /* Reserved */
  572.     unsigned char pageControl    :2;    /* Page Control */
  573.     unsigned char pageCode    :6;    /* Page Code */
  574.     unsigned char pad3;            /* Reserved */
  575.     unsigned char allocLen;        /* Allocation length. */
  576.     unsigned char vendor    :2;    /* Vendor unique. */
  577.     unsigned char pad4        :6;    /* Reserved */
  578. #else
  579.     unsigned char command;        /* 0x1b */
  580.     unsigned char pad2        :3;    /* Reserved */
  581.     unsigned char disableBlockDesc :1;    /* Disable block descriptor */
  582.     unsigned char pad1        :1;    /* Reserved */
  583.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  584.                      * pass the command.  The device
  585.                      * has already been selected using
  586.                      * the "targetID" bit. */
  587.     unsigned char pageCode    :6;    /* Page Code */
  588.     unsigned char pageControl    :2;    /* Page Control */
  589.     unsigned char pad3;            /* Reserved */
  590.     unsigned char allocLen;        /* Allocation length. */
  591.     unsigned char pad4        :6;    /* Reserved */
  592.     unsigned char vendor    :2;    /* Vendor unique. */
  593. #endif
  594. } ScsiModeSenseCmd;
  595.  
  596. /*
  597.  * Block descriptor returned by mode sense.
  598.  */
  599.  
  600. typedef struct {
  601.     unsigned char    density;    /* Density code. */
  602.     unsigned char    num2;        /* MSB of number of blocks. */
  603.     unsigned char    num1;        /* ... */
  604.     unsigned char    num0;        /* LSB of number of blocks. */
  605.     unsigned char    pad0;        /* Reserved. */
  606.     unsigned char    len2;        /* MSB of block length. */
  607.     unsigned char    len1;        /* ... */
  608.     unsigned char    len0;        /* LSB of block length. */
  609. } ScsiBlockDesc;
  610.  
  611. /*
  612.  * Format of a SCSI_REQUEST_SENSE command.
  613.  */
  614. typedef struct {
  615. #if BYTE_ORDER == BIG_ENDIAN
  616.     unsigned char command;        /* 0x1b */
  617.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  618.                      * pass the command.  The device
  619.                      * has already been selected using
  620.                      * the "targetID" bit. */
  621.     unsigned char pad1        :5;    /* Reserved */
  622.     unsigned char pad2;            /* Reserved */
  623.     unsigned char pad3;            /* Reserved */
  624.     unsigned char allocLen;        /* Allocation length. */
  625.     unsigned char clearCount    :1;    /* Clear counters. */
  626.     unsigned char vendor    :1;    /* Vendor unique. */
  627.     unsigned char pad4        :6;    /* Reserved */
  628. #else
  629.     unsigned char command;        /* 0x1b */
  630.     unsigned char pad1        :5;    /* Reserved */
  631.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  632.                      * pass the command.  The device
  633.                      * has already been selected using
  634.                      * the "targetID" bit. */
  635.     unsigned char pad2;            /* Reserved */
  636.     unsigned char pad3;            /* Reserved */
  637.     unsigned char allocLen;        /* Allocation length. */
  638.     unsigned char pad4        :6;    /* Reserved */
  639.     unsigned char vendor    :1;    /* Vendor unique. */
  640.     unsigned char clearCount    :1;    /* Clear counters. */
  641. #endif
  642. } ScsiRequestSenseCmd;
  643.  
  644. /*
  645.  * Format of a SCSI_READ_POSITION command.
  646.  */
  647.  
  648. typedef struct {
  649. #if BYTE_ORDER == BIG_ENDIAN
  650.     unsigned char command;        /* 0x34 */
  651.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  652.                      * pass the command.  The device
  653.                      * has already been selected using
  654.                      * the "targetID" bit. */
  655.     unsigned char pad1        :4;    /* Reserved */
  656.     unsigned char blockType    :1;    /* Block type. */
  657.     unsigned char pad2;            /* Reserved */
  658.     unsigned char pad3;            /* Reserved */
  659.     unsigned char pad4;            /* Reserved */
  660.     unsigned char pad5;            /* Reserved */
  661.     unsigned char pad6;            /* Reserved */
  662.     unsigned char pad7;            /* Reserved */
  663.     unsigned char pad8;            /* Reserved */
  664.     unsigned char vendor    :2;    /* Vendor unique. */
  665.     unsigned char pad9        :6;    /* Reserved */
  666. #else
  667.     unsigned char command;        /* 0x34 */
  668.     unsigned char blockType    :1;    /* Block type. */
  669.     unsigned char pad1        :4;    /* Reserved */
  670.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  671.                      * pass the command.  The device
  672.                      * has already been selected using
  673.                      * the "targetID" bit. */
  674.     unsigned char pad2;            /* Reserved */
  675.     unsigned char pad3;            /* Reserved */
  676.     unsigned char pad4;            /* Reserved */
  677.     unsigned char pad5;            /* Reserved */
  678.     unsigned char pad6;            /* Reserved */
  679.     unsigned char pad7;            /* Reserved */
  680.     unsigned char pad8;            /* Reserved */
  681.     unsigned char pad9        :6;    /* Reserved */
  682.     unsigned char vendor    :2;    /* Vendor unique. */
  683. #endif
  684. } ScsiReadPositionCmd;
  685.  
  686. /*
  687.  * Result of a SCSI_READ_POSITION command.
  688.  */
  689.  
  690. typedef struct {
  691. #if BYTE_ORDER == BIG_ENDIAN
  692.     unsigned char bop        :1;    /* Beginning of partition. */
  693.     unsigned char eop        :1;    /* End of partition. */
  694.     unsigned char pad0a        :3;    /* Reserved. */
  695.     unsigned char bpu        :1;    /* Block position unknown. */
  696.     unsigned char pad0b        :2;    /* Reserved. */
  697.     unsigned char partition;        /* Partition number. */
  698.     unsigned char pad2;            /* Reserved. */
  699.     unsigned char pad3;            /* Reserved. */
  700.     unsigned char firstBlock3;        /* First block location, MSB */
  701.     unsigned char firstBlock2;        /* ... */
  702.     unsigned char firstBlock1;        /* ... */
  703.     unsigned char firstBlock0;        /* First block location, LSB */
  704.     unsigned char lastBlock3;        /* Last block location, MSB */
  705.     unsigned char lastBlock2;        /* ... */
  706.     unsigned char lastBlock1;        /* ... */
  707.     unsigned char lastBlock0;        /* Last block location, LSB */
  708.     unsigned char pad12;        /* Reserved. */
  709.     unsigned char blocksInBuf2;        /* Blocks in buffer, MSB. */
  710.     unsigned char blocksInBuf1;        /* ... */
  711.     unsigned char blocksInBuf0;        /* Blocks in buffer, LSB. */
  712.     unsigned char bytesInBuf3;        /* Bytes in buffer, MSB. */
  713.     unsigned char bytesInBuf2;        /* ... */
  714.     unsigned char bytesInBuf1;        /* ... */
  715.     unsigned char bytesInBuf0;        /* Bytes in buffer, LSB. */
  716. #else
  717.     unsigned char pad0b        :2;    /* Reserved. */
  718.     unsigned char bpu        :1;    /* Block position unknown. */
  719.     unsigned char pad0a        :3;    /* Reserved. */
  720.     unsigned char eop        :1;    /* End of partition. */
  721.     unsigned char bop        :1;    /* Beginning of partition. */
  722.     unsigned char partition;        /* Partition number. */
  723.     unsigned char pad2;            /* Reserved. */
  724.     unsigned char pad3;            /* Reserved. */
  725.     unsigned char firstBlock3;        /* First block location, MSB */
  726.     unsigned char firstBlock2;        /* ... */
  727.     unsigned char firstBlock1;        /* ... */
  728.     unsigned char firstBlock0;        /* First block location, LSB */
  729.     unsigned char lastBlock3;        /* Last block location, MSB */
  730.     unsigned char lastBlock2;        /* ... */
  731.     unsigned char lastBlock1;        /* ... */
  732.     unsigned char lastBlock0;        /* Last block location, LSB */
  733.     unsigned char pad12;        /* Reserved. */
  734.     unsigned char blocksInBuf2;        /* Blocks in buffer, MSB. */
  735.     unsigned char blocksInBuf1;        /* ... */
  736.     unsigned char blocksInBuf0;        /* Blocks in buffer, LSB. */
  737.     unsigned char bytesInBuf3;        /* Bytes in buffer, MSB. */
  738.     unsigned char bytesInBuf2;        /* ... */
  739.     unsigned char bytesInBuf1;        /* ... */
  740.     unsigned char bytesInBuf0;        /* Bytes in buffer, LSB. */
  741. #endif
  742. } ScsiReadPositionResult;
  743.  
  744. /*
  745.  * Format of SCSI_LOCATE command.
  746.  */
  747.  
  748. typedef struct {
  749. #if BYTE_ORDER == BIG_ENDIAN
  750.     unsigned char command;        /* 0x2b */
  751.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  752.                      * pass the command.  The device
  753.                      * has already been selected using
  754.                      * the "targetID" bit. */
  755.     unsigned char pad1        :2;    /* Reserved */
  756.     unsigned char blockType    :1;    /* Block type. */
  757.     unsigned char changePartition :1;    /* Change partitions. */
  758.     unsigned char immediate    :1;    /* Immediate. */
  759.     unsigned char pad2;            /* Reserved */
  760.     unsigned char addr3;        /* Block address, MSB */
  761.     unsigned char addr2;        /* ... */
  762.     unsigned char addr1;        /* ... */
  763.     unsigned char addr0;        /* Block address, LSB */
  764.     unsigned char pad7;            /* Reserved */
  765.     unsigned char partition;        /* Partition */
  766.     unsigned char vendor    :2;    /* Vendor unique. */
  767.     unsigned char pad9        :6;    /* Reserved */
  768. #else
  769.     unsigned char command;        /* 0x2b */
  770.     unsigned char immediate    :1;    /* Immediate. */
  771.     unsigned char changePartition :1;    /* Change partitions. */
  772.     unsigned char blockType    :1;    /* Block type. */
  773.     unsigned char pad1        :2;    /* Reserved */
  774.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  775.                      * pass the command.  The device
  776.                      * has already been selected using
  777.                      * the "targetID" bit. */
  778.     unsigned char pad2;            /* Reserved */
  779.     unsigned char addr3;        /* Block address, MSB */
  780.     unsigned char addr2;        /* ... */
  781.     unsigned char addr1;        /* ... */
  782.     unsigned char addr0;        /* Block address, LSB */
  783.     unsigned char pad7;            /* Reserved */
  784.     unsigned char partition;        /* Partition */
  785.     unsigned char pad9        :6;    /* Reserved */
  786.     unsigned char vendor    :2;    /* Vendor unique. */
  787. #endif
  788. } ScsiLocateCmd;
  789.  
  790. /*
  791.  * Format of SCSI_PREVENT_ALLOW command.
  792.  */
  793.  
  794. typedef struct {
  795. #if BYTE_ORDER == BIG_ENDIAN
  796.     unsigned char command;        /* 0x1e */
  797.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  798.                      * pass the command.  The device
  799.                      * has already been selected using
  800.                      * the "targetID" bit. */
  801.     unsigned char pad1        :5;    /* Reserved. */
  802.     unsigned char pad2;            /* Reserved. */
  803.     unsigned char pad3;            /* Reserved. */
  804.     unsigned char pad4        :7;    /* Reserved. */
  805.     unsigned char prevent    :1;    /* 0 = allow, 1 = prevent */
  806.     unsigned char vendor    :2;    /* Vendor unique. */
  807.     unsigned char pad5        :6;    /* Reserved */
  808. #else
  809.     unsigned char command;        /* 0x1e */
  810.     unsigned char pad1        :5;    /* Reserved. */
  811.     unsigned char unitNumber    :3;    /* Logical Unit (LUN) to which to
  812.                      * pass the command.  The device
  813.                      * has already been selected using
  814.                      * the "targetID" bit. */
  815.     unsigned char pad2;            /* Reserved. */
  816.     unsigned char pad3;            /* Reserved. */
  817.     unsigned char prevent    :1;    /* 0 = allow, 1 = prevent */
  818.     unsigned char pad4        :7;    /* Reserved. */
  819.     unsigned char pad5        :6;    /* Reserved */
  820.     unsigned char vendor    :2;    /* Vendor unique. */
  821. #endif
  822. } ScsiPreventAllowCmd;
  823.  
  824. /*
  825.  * Format of a SCSI Inquiry Command.
  826.  */
  827.  
  828. typedef struct ScsiInquiryCommand {
  829. #if BYTE_ORDER == BIG_ENDIAN
  830.     unsigned char command;        /* 0x12 for SCSI Inquiry. */
  831.  
  832.     unsigned char unitNumber    :3;     /* Logical Unit Number to which
  833.                          * to pass the command. */
  834.     unsigned char reserved    :4;     
  835.     unsigned char evpd        :1;     /* Enable Vital Product Data. Selects
  836.                      * The type of inquiry data requested
  837.                      * by the initiator. */
  838.     unsigned char pageCode;        
  839.     unsigned char reserved2;        
  840.     unsigned char allocLength;        /* The number of bytes that the
  841.                      * initiator has allocated for
  842.                      * data returned from the Inquiry
  843.                      * command. */
  844.     unsigned char vendorUnique    :2;     /* Vendor Unique bits. */
  845.     unsigned char reserved3    :4;
  846.     unsigned char flag        :1;     /* Interrupt after linked command. */
  847.     unsigned char link        :1;     /* Another command follows. */
  848. #else /* BYTE_ORDER == LITTLE_ENDIAN */
  849.     unsigned char command;        /* 0x12 for SCSI Inquiry. */
  850.  
  851.     unsigned char evpd        :1;    /* Enable Vital Product Data. Selects
  852.                      * The type of inquiry data requested
  853.                      * by the initiator. */
  854.     unsigned char reserved    :4;
  855.     unsigned char unitNumber    :3;    /* Logical Unit Number to which
  856.                      * to pass the command. */
  857.     unsigned char pageCode;
  858.     unsigned char reserved2;
  859.     unsigned char allocLength;        /* The number of bytes that the
  860.                      * initiator has allocated for data
  861.                      * returned from the Inquiry command.
  862.                      */
  863.     unsigned char link        :1;    /* Another command follows. */
  864.     unsigned char flag        :1;    /* Interrupt after linked command. */
  865.     unsigned char reserved3    :4;
  866.     unsigned char vendorUnique    :2;    /* Vendor Unique bits. */
  867. #endif
  868. } ScsiInquiryCommand;
  869.  
  870.  
  871. /*
  872.  * Format of a SCSI Mode Select command.
  873.  */
  874.  
  875. typedef struct ScsiModeSelectCommand {
  876. #if BYTE_ORDER == BIG_ENDIAN
  877.     unsigned char command;        /* 0x15, for Mode Select */
  878.     unsigned char unitNumber    :3;    /* Logical Unit Number to which
  879.                      * to pass the command. */
  880.     unsigned char pageFormat    :1;    /* 1 == SCSI-2;
  881.                      * Must be 1 for Exabyte robot. */
  882.     unsigned char reserved    :3;    
  883.     unsigned char savedPage    :1;    /* 0 == Changes are not permanent.
  884.                      * 1 == Changes are permanent
  885.                      * (stored in non-volatile memory).*/
  886.     unsigned char reserved2[2];
  887.     unsigned char paramListLength;    /* Length of the entire parameter
  888.                      * list. */
  889.     unsigned char vendorUnique    :2;    
  890.     unsigned char reserved3    :4;
  891.     unsigned char flag        :1;    /* Interrupt after linked command. */
  892.     unsigned char link        :1;    /* Another command follows. */
  893. #else /* BYTE_ORDER == LITTLE_ENDIAN */
  894.     unsigned char command;        /* 0x15, for Mode Select */
  895.     unsigned char savedPage    :1;    /* 0 == Changes are not permanent.
  896.                      * 1 == Changes are permanent
  897.                      * (stored in non-volatile memory).*/
  898.     unsigned char reserved    :3;
  899.     unsigned char pageFormat    :1;    /* 1 == SCSI-2;
  900.                      * Must be 1 for Exabyte robot. */
  901.     unsigned char unitNumber    :3;    /* Logical Unit Number to which
  902.                      * to pass the command. */
  903.     unsigned char reserved2[2];
  904.     unsigned char paramListLength;    /* Length of the entire parameter
  905.                      * list. */
  906.     unsigned char link        :1;    /* Another command follows. */
  907.     unsigned char flag        :1;    /* Interrupt after linked command. */
  908.     unsigned char reserved3    :4;
  909.     unsigned char vendorUnique    :2;
  910. #endif
  911. } ScsiModeSelectCommand;
  912.  
  913.  
  914. /*
  915.  * Format of a SCSI Reserve Command.
  916.  */
  917.  
  918. typedef struct ScsiReserveCommand {
  919. #if BYTE_ORDER == BIG_ENDIAN
  920.     unsigned char command;        /* 0x16 for Reserve Command. */
  921.     unsigned char unitNumber    :3;    /* Logical Unit Number to which to
  922.                      * pass the command. */
  923.     unsigned char thirdParty    :1;
  924.     unsigned char thirdPartyDevID:3;
  925.     unsigned char extent    :1;    /* 0 == The device is reserved.
  926.                      * 1 == A series of elements,
  927.                      *      identified by the reserveID
  928.                      *      field and specified by the
  929.                      *      element list descriptor
  930.                      *      are reserved. A minimum of
  931.                      *      six bytes must be sent by
  932.                      *      the initiator. */
  933.     unsigned char reserveID;
  934.     unsigned char elemListLength[2];
  935.     unsigned char vendorUnique    :2;
  936.     unsigned char reserved    :4;
  937.     unsigned char flag        :1;
  938.     unsigned char link        :1;
  939. #else /* BYTE_ORDER == LITTLE_ENDIAN */
  940.     unsigned char command;
  941.     unsigned char extent    :1;    /* 0 == The device as a whole
  942.                      *      is reserved.
  943.                      * 1 == A series of elements,
  944.                      *      identified by the reserveID
  945.                      *      field and specified by the
  946.                      *      element list descriptor
  947.                      *      are reserved. A minimum of
  948.                      *      six bytes must be sent by
  949.                      *      the initiator. */
  950.     unsigned char thirdPartyDevID:3;
  951.     unsigned char thirdParty    :1;
  952.     unsigned char unitNumber    :3;    /* Logical Unit Number to which to
  953.                      * pass the command. */
  954.     unsigned char reserveID;
  955.     unsigned char elemListLength[2];
  956.     unsigned char link        :1;    
  957.     unsigned char flag        :1;
  958.     unsigned char reserved    :4;
  959.     unsigned char vendorUnique    :2;
  960. #endif
  961. } ScsiReserveCommand;
  962.  
  963.  
  964. #endif /* _SCSI_H */
  965.  
  966.  
  967. @
  968.  
  969.  
  970. 1.3
  971. log
  972. @changed SCSI_MAX_SENSE_LEN to be bytes
  973. @
  974. text
  975. @d23 1
  976. a23 1
  977.  * $Header: /sprite/src/lib/include/sys/RCS/scsi.h,v 1.2 91/07/26 17:14:40 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  978. d111 8
  979. d785 138
  980. d926 2
  981. @
  982.  
  983.  
  984. 1.2
  985. log
  986. @Added a couple more scsi commands. (checked in by shirriff)
  987. @
  988. text
  989. @d23 1
  990. a23 1
  991.  * $Header: /sprite/src/lib/include/sys/RCS/scsi.h,v 1.1 91/06/25 15:20:22 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  992. d300 1
  993. a300 1
  994.  * Maximum size of sense data that a device can return. XXX - fix this.
  995. d302 1
  996. a302 1
  997. #define    SCSI_MAX_SENSE_LEN    64
  998. @
  999.  
  1000.  
  1001. 1.1
  1002. log
  1003. @Initial revision
  1004. @
  1005. text
  1006. @d23 1
  1007. a23 1
  1008.  * $Header: /sprite/src/kernel/dev/RCS/scsi.h,v 9.3 91/04/12 17:54:22 jhh Exp $ SPRITE (Berkeley)
  1009. d29 5
  1010. d105 6
  1011. d695 81
  1012. a775 1
  1013. } ScsiReadPositionResult
  1014. @
  1015.